<template>
    <div id="app">
      <el-form :model="car" label-width="100px">

        <el-form-item label="车牌号" prop="name">
          <el-input v-model="car.carNo"></el-input>
        </el-form-item>
        <el-form-item label="业主">
          <el-select v-model="car.oid" placeholder="请选择">
            <el-option
              v-for="item in userList"
              :key="item.uid"
              :label="item.uname"
              :value="item.uid">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click.prevent="test">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
    export default {
      data(){
        return {
          car:{},
          userList:[]

        }
      },
      created() {
        this.axios.get("/user/getAll").then((resp)=>{
            this.userList=resp.data;
          }
        )
      },
      methods:{
        test(){

            this.$confirm("是否确认提交","保存提示").then(()=>{
              this.axios.post("/car/add",this.car).then((resp)=>{
                  this.$message.success("保存成功！");
                  this.$router.push("/car/CarList")
                });
            });

        },

      }
    }
</script>


<style scoped>

</style>
